﻿using ExpressesClass.SfApi.Util;

namespace ExpressesClass.SfApi.Base
{
    public class Request
    {
        private string service;
        public Request(string service)
        {
            this.service = service;
        }
        public Response Execute(string reqURL, object body, string clientCode, string checkword)
        {
            try
            {
                CallExpressServiceTools tools = CallExpressServiceTools.getInstance();
                string xml = tools.callSfExpressServiceByCSIM(reqURL, Create(this.service, clientCode, body), checkword);
                Response res = new Response(xml);
                return res;
            }
            catch
            {
                return null;
            }
        }
        private string Create(string service, string clientCode, object body)
        {
            return "<Request service=\"" + service + "\" lang=\"zh-CN\"><Head>" + clientCode + "</Head><Body>" + XmlUtil.ObjToXml(body) + "</Body></Request>";
        }
    }
}
